/**
 * 闹钟
 * 
 * 属性：类型  时间  重复  标签  声音类型  铃声   打盹方式  关闭方式  重响间隔  上班时间（选填）
 */

package org.dreamfly.dreamalarm.bean;

import java.util.Calendar;

import org.dreamfly.dreamalarm.util.DreamAlarmDateFormat;

public class Alarm extends AlarmFather{
	// ------------------------------------------------------------
	// attribute & set get

	/**
	 * 
	 */
	private static final long serialVersionUID = 6997993681983957482L;
	
	private int id = -1;
	private int type = -1; // 闹钟类型
	private int state=1; // 状态：1开启 0关闭
	private String time = ""; // 闹钟时间
	private int repeat = -1; // 1111111表示每天
	private String tag = ""; // 显示标签   can be null
	private String ringSource = ""; // 铃声资源 content://…… 空表示静音
	private int endType = 0; // 关闭方式
	private int reringInterval = 0; // 重响间隔（分钟）
	private String workTime = ""; // 起床铃记录上班时间  提醒时可以为空

	public int getId() {
		return id;
	}

	public String getIdString() {
		return "" + id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}
	
	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getTime() {
		if(this.time.length()==5){
			return time+":00";
		}
		return time;
	}
	
	public String getTimeView(){
		if(this.time.length()==8){
			return time.substring(0,5);
		}
		return time;
	}

	public Calendar getTimeDate() {
		return DreamAlarmDateFormat.stringToTime(time);
	}

	public void setTime(String time) {
		this.time = time;
	}

	public void setTime(Calendar calendar) {
		this.time = DreamAlarmDateFormat.timeToString(calendar);
	}

	public int getRepeat() {
		return repeat;
	}

	public void setRepeat(int repeat) {
		this.repeat = repeat;
	}

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public String getRingSource() {
		return ringSource;
	}

	public void setRingSource(String ringSource) {
		this.ringSource = ringSource;
	}
	
	public boolean isSilence(){
		if(this.ringSource.equals("") ||
				this.ringSource.equals("content://")){
			return true;
		}
		return false;
	}

	public int getEndType() {
		return endType;
	}

	public void setEndType(int endType) {
		this.endType = endType;
	}

	public int getReringInterval() {
		return reringInterval;
	}

	public int getReringIntervalMillis() {
		return reringInterval * 60 * 1000;
	}

	public void setReringInterval(int reringInterval) {
		this.reringInterval = reringInterval;
	}

	public String getWorkTime() {
		return workTime;
	}

	public Calendar getWorkTimeDate() {
		return DreamAlarmDateFormat.stringToTime(workTime);
	}

	public void setWorkTime(String workTime) {
		this.workTime = workTime;
	}

	public void setWorkTime(Calendar calendar) {
		this.workTime = DreamAlarmDateFormat.timeToString(calendar);
	}
}
